package com.jcli._java_swing_入门教程pdf.ch17;

import com.jcli.util.GUIUtil;

import javax.swing.*;

/**
 * @author li
 * @version 1.0
 * @belongsProject novel_20230923
 * @belongsPackage com.jcli._java_swing_入门教程pdf.ch17
 * @className _05_JRadioButton
 * @description TODO  四季单选框
 * @createTime 2024-01-25  20:47
 */
public class _05_JRadioButton extends JPanel {
    public static _05_JRadioButton instance = new _05_JRadioButton();

    public static void main(String[] args) {
        GUIUtil.showJPanel("单选按钮组件实例", instance);
    }

    public _05_JRadioButton() {
        Icon icon = new ImageIcon("pic/1Snipaste_2023-12-25_12-02-52.png");
        //    创建单选按钮对象
        JRadioButton jr1 = new JRadioButton("春季");
        JRadioButton jr2 = new JRadioButton("夏季");
        JRadioButton jr3 = new JRadioButton("秋季");
        JRadioButton jr4 = new JRadioButton("冬季", true);
        //    创建文本标签并设置字体样式
        JLabel label = new JLabel("现在是哪个季节?");
        label.setFont(GUIUtil.font);
        //    将按钮放入ButtonGroup
        ButtonGroup bg = new ButtonGroup();
        // bg.add(jr1);
        bg.add(jr2);
        bg.add(jr3);
        bg.add(jr4);
        //    按钮加入面板
        add(label);
        add(jr1);
        add(jr2);
        add(jr3);
        add(jr4);
    }
}
